<?php
header("Content-type:text/html; charset=utf-8");
require_once ('include/conn.php');
class System{
	/*网站网址*/
	private $website;
	/*界面风格*/
	private $web_style;
	/*首页模板*/
	private $index_model;
	/*首页视频*/
	private $index_movie;
	/*栏目模型*/
	private $channel_model;
	/*文章模型*/
	private $article_model;
	/*搜索页模板*/
	private $search_model;
	/*模板*/
	private $templates;

	function __construct(){
		$this->website="";
		$this->web_style="";
		$this->index_model="";
		$this->channel_model="";
		$this->article_model="";
		$this->search_model="";
		$this->templates=array();
	}
	
	/*获取网站网址*/
	function getWebSite(){
		$sql_get_website="select sysconfig_value from sysconfig where sysconfig_name='website'";
		$result_get_website=mysql_query($sql_get_website)or die(mysql_error());
		$row_get_website=mysql_fetch_object($result_get_website);
		$this->website= @$row_get_website->sysconfig_value;
		return $this->website;
	}
	/*获取界面风格*/
	function getSysStyle(){
		$sql_get_sys_style="select sysconfig_value from sysconfig where sysconfig_name='sys_style'";
		$result_get_sys_style=mysql_query($sql_get_sys_style)or die(mysql_error());
		$row_get_sys_style=mysql_fetch_object($result_get_sys_style);
		$this->web_style= @$row_get_sys_style->sysconfig_value;
		return $this->web_style;
	}

	/*获取主页模版*/
	function getIndexModel(){
		$sql_get_index_model="select sysconfig_value from sysconfig where sysconfig_name='index_model'";
		$result_get_index_model=mysql_query($sql_get_index_model)or die(mysql_error());
		$row_get_index_model=mysql_fetch_object($result_get_index_model);
		$this->index_model= @$row_get_index_model->sysconfig_value;
		return $this->index_model;
	}
	/*获取主页视频*/
	function getIndexMovie(){
		$sql_get_index_movie="select sysconfig_value from sysconfig where sysconfig_name='index_movie'";
		$result_get_index_movie=mysql_query($sql_get_index_movie)or die(mysql_error());
		$row_get_index_movie=mysql_fetch_object($result_get_index_movie);
		$this->index_movie= @$row_get_index_movie->sysconfig_value;
		return $this->index_movie;
	}
	
	/*获取搜索页模版*/
	function getSearchModel(){
		$sql_get_search_model="select sysconfig_value from sysconfig where sysconfig_name='search_model'";
		$result_get_search_model=mysql_query($sql_get_search_model)or die(mysql_error());
		$row_get_search_model=mysql_fetch_object($result_get_search_model);
		$this->search_model= @$row_get_search_model->sysconfig_value;
		return $this->search_model;
	}
	/*获取指定id的栏目的模版*/
	function getChannelModel($channel_id){
		$sql_get_channel_model="select channel_model from channel where channel_id=$channel_id;";
		$result_get_channel_model=mysql_query($sql_get_channel_model)or die(mysql_error());
		$row_get_channel_model=mysql_fetch_object($result_get_channel_model);
		$this->channel_model=@$row_get_channel_model->channel_model;
		return $this->channel_model;
	}
	/*获取指定id的栏目的文章模版*/
	function getArticleModel($channel_id){
		$sql_get_article_model="select article_model from channel where channel_id=$channel_id;";
		$result_get_article_model=mysql_query($sql_get_article_model)or die(mysql_error());
		$row_get_article_model=mysql_fetch_object($result_get_article_model);
		$this->article_model=@$row_get_article_model->article_model;
		return $this->article_model;
	}
	/*获取现有界面风格*/
	function getTemplates(){
		$i=0;
		$template_path="../templates/";
		$hander=opendir($template_path);
		while(($filename=readdir($hander))!==false){
			if(!(substr($filename,0,1)==".")){
				if(is_dir($template_path.$filename)){
					$this->templates[$i++]=$filename;
				}
			}
		}
		closedir($hander);

		if(count($this->templates)==0){
			return "";
		}
          return join("|", $this->templates);
	}
}